package com.hrt.iceberg

import org.apache.spark.sql.SparkSession

/**
 * 读取 StructuredStreaming 写入Iceberg中的数据结果
 */
object GetSturcturedIcebergResult {
  def main(args: Array[String]): Unit = {
    //1.准备对象
    val spark: SparkSession = SparkSession.builder().master("local").appName("StructuredSinkIceberg")
      //指定hadoop catalog，catalog名称为hadoop_prod
      .config("spark.sql.catalog.hadoop_prod", "org.apache.iceberg.spark.SparkCatalog")
      .config("spark.sql.catalog.hadoop_prod.type", "hadoop")
      .config("spark.sql.catalog.hadoop_prod.warehouse", "hdfs://mycluster/structuredstreaming")
      .getOrCreate()

    //2.读取Iceberg 表中的数据结果
    spark.sql(
      """
        |select * from hadoop_prod.iceberg_db.iceberg_table
      """.stripMargin).show()


  }

}
